package Yang.dao;

import Yang.pojo.User;
import org.apache.ibatis.annotations.*;

import java.util.List;

public interface UserMapper {
    @Select("select * from user")
    List<User> getUsers();

    //这里的sql语句中的id对应@Param("id")的id，而并不是参数id
    @Select("select * from user where id = #{id}")
    User getUserById(@Param("id") int id);
    //有多个参数，所有的参数前面必须加上注解
    //User getUserById(@Param("id") int id,@Param("name")String name);

    //#{}中的字段需要和实体类中的相对应
    @Insert("insert into user(id,name,pwd) values (#{id},#{name},#{password})")
    int addUser(User user);//引用对象不需要写@Param()

    @Update("update user set name = #{name},pwd=#{password} where id=#{id}")
    int updateUser(User user);

    @Delete("delete from user where id=#{uid}")
    int deleteUser(@Param("uid") int id);
}
